package csdn;

import java.util.*;

/**
 * 项目名称：wangxu
 * 类 名 称：匿名信
 * 描 述：https://dream.blog.csdn.net/article/details/129487967
 * 创建时间：2023/4/9 7:15 下午
 * 创 建 人：wang-xu
 */
public class RealTopic14 {
    public static void main(String[] args) {
        try {
            Scanner in = new Scanner(System.in);
            String newspaper = in.nextLine();
            String anonymousLetter = in.nextLine();
            if (newspaper.length() < 1 || newspaper.length() > 10*10*10*10 || newspaper.isEmpty()){
                System.out.println("input error");
                return;
            }
            if (anonymousLetter.length() < 1 || anonymousLetter.length() > 10*10*10*10 || anonymousLetter.isEmpty()){
                System.out.println("input error");
                return;
            }
            List<String> newspaperList = returnList(newspaper);
            List<String> anonymousLetterList = returnList(anonymousLetter);
            boolean result = false;
            if (!anonymousLetterList.isEmpty()){
                for (String s:anonymousLetterList) {
                    if (newspaper.contains(s)){
                        result = true;
                        System.out.println(result);
                    }else {
                        System.out.println(result);
                    }
                    return;
                }
            }


        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static List<String> returnList(String str){
        List<String> list = new ArrayList<>();
        String[] strs = str.split(" ");
        if (strs.length < 1 ||strs.length > 100){
            return null;
        }

        for (String s:strs) {
            char[] chars = s.toCharArray();
            Arrays.sort(chars);
            list.add(new String(chars));
        }

        return list;
    }
}
